<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
<meta charset="UTF-8">
<title>个人二维码支付测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	function testpay() {
		var data = {};
		data.platformId = document.getElementById('platformId').value;
		data.merchantId = document.getElementById('merchantId').value;
		data.orderAmt = document.getElementById('orderAmt').value;
		data.payAmt = document.getElementById('payAmt').value;
		data.body = document.getElementById('body').value;
        data.customerId = document.getElementById('customerId').value;
        data.payAccount = document.getElementById('payAccount').value;
        data.nickname = document.getElementById('nickname').value;
        data.realname = document.getElementById('realname').value;
		data.payCode = '1';
		var style = '';
		var payStyle = document.getElementsByName('payStyle');
		for (var i = 0; i < payStyle.length; i++) {
			if (payStyle[i].checked == true) {
				data.payStyle = payStyle[i].value;
				style = payStyle[i].value;
			}
		}
		var payType = document.getElementsByName('payType');
		for (var i = 0; i < payType.length; i++) {
			if (payType[i].checked == true) {
				data.payType = payType[i].value;
			}
		}
		data.payChannelNo = 'payhelper001';
		data.payCompanyNo = 'OTHER';
		var payType = document.getElementById('payType').value;
		
		$.ajax({
			type: "POST",//传输方式
			contentType: "application/json",
			url: "pay/createAndPay",//action路径
			data: JSON.stringify(data),
			success: function(msg){
				//调用成功后执行操作
				console.log("支付结果。。。。。。",msg)
				if('0000' == msg.code){
					var payOrderNo = msg.payOrderNo;
					var sendGet = msg.payObject.sendGet;
					var qrCode = document.getElementById('qrCode');
					if('0' == style){
						//动态码
						qrCode.innerHTML = sendGet
					}else if('1' == style){
						//静态码
						console.log("支付结果。。。。。。",sendGet)
						document.getElementById('sendGet').src = sendGet
					}
					
				}else{
					alert("错误信息："+msg.msg)
				}
			}
		});
	}
	
 	</script>
</head>
<body>

	<div align="center">
		<br />
		<br /> 平台编号: <input type="text" id="platformId" th:value="14376521810391040"><br />
		<br /> 商户号: <input type="text" id="merchantId" th:value="15806546854883328"><br />
		<br /> 第三方网站会员号: <input type="text" id="customerId" th:value="12124343434"><br />
		<br /> 订单金额: <input type="text" id="orderAmt" th:value="0.01"><br />
		<br /> 实际支付金额: <input type="text" id="payAmt" th:value="0.01"><br />
		<br /> 商品信息: <input type="text" id="body" th:value="个人二维码支付测试"><br />
		<br /> 付款人支付宝账号: <input type="text" id="payAccount"><br />
		<br /> 付款人支付宝昵称: <input type="text" id="nickname"><br />
		<br /> 付款人支付宝真实姓名: <input type="text" id="realname"><br />
		<br /> 支付类型: <input id="payStyle" name="payStyle" type="radio"
			th:value="0" />动态码
			<input id="payStyle"
			name="payStyle" type="radio" checked="checked" th:value="1" />静态码<br />
		<br /> <input id="payType" name="payType" type="radio"
			th:value="wechat" />微信 
			<input id="payType"
			name="payType" type="radio" checked="checked" th:value="alipay" />支付宝

		<div align="center">
			<p>
				<input type="Submit" id="submit_btn" value="发起支付"
					onclick="testpay()" />
			</p>
		</div>
		<br />
		<div id="qrCode">
		</div>
		<img src="" id="sendGet">
	</div>

</body>
</html>